{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "848adc53-1412-4228-a9a1-1289a16cf20a",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:04.180451Z",
     "shell.execute_reply.started": "2023-03-10T04:58:04.174274Z",
     "to_execute": "2023-03-10T04:58:04.081Z"
    },
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# pip install scipy==1.2 --upgrade\n",
    "# pip install pandas==0.24 --upgrade\n",
    "# 'factorial' from 'scipy.misc'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a4fa8d15-dd3d-45e1-b778-1c82709e04be",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:05.618915Z",
     "shell.execute_reply.started": "2023-03-10T04:58:05.608690Z",
     "to_execute": "2023-03-10T04:58:05.518Z"
    },
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import random\n",
    "from trailblazer4ml.causal_discovery.datasets.easydataset import EasyDataset\n",
    "from trailblazer4ml.causal_discovery.estimators.FCM_based import FCM\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1b46190c-f81a-4367-8512-fb047d7cd01b",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:09.814283Z",
     "shell.execute_reply.started": "2023-03-10T04:58:09.718180Z",
     "to_execute": "2023-03-10T04:58:09.626Z"
    },
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>treat</th>\n",
       "      <th>age</th>\n",
       "      <th>educ</th>\n",
       "      <th>black</th>\n",
       "      <th>hispan</th>\n",
       "      <th>married</th>\n",
       "      <th>nodegree</th>\n",
       "      <th>re74</th>\n",
       "      <th>re75</th>\n",
       "      <th>re78</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>37</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9930.0460</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3595.8940</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>30</td>\n",
       "      <td>12</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>24909.4500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>27</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7506.1460</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>33</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>289.7899</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "      <td>9</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4056.4940</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1</td>\n",
       "      <td>23</td>\n",
       "      <td>12</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1</td>\n",
       "      <td>32</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>8472.1580</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1</td>\n",
       "      <td>22</td>\n",
       "      <td>16</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2164.0220</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1</td>\n",
       "      <td>33</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12418.0700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1</td>\n",
       "      <td>19</td>\n",
       "      <td>9</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>8173.9080</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1</td>\n",
       "      <td>21</td>\n",
       "      <td>13</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>17094.6400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>1</td>\n",
       "      <td>18</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1</td>\n",
       "      <td>27</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>18739.9300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1</td>\n",
       "      <td>17</td>\n",
       "      <td>7</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3023.8790</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1</td>\n",
       "      <td>19</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3228.5030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1</td>\n",
       "      <td>27</td>\n",
       "      <td>13</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>14581.8600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1</td>\n",
       "      <td>23</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7693.4000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "      <td>12</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10804.3200</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>1</td>\n",
       "      <td>26</td>\n",
       "      <td>12</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10747.3500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1</td>\n",
       "      <td>23</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1</td>\n",
       "      <td>41</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5149.5010</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1</td>\n",
       "      <td>38</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6408.9500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>1</td>\n",
       "      <td>24</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1991.4000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>1</td>\n",
       "      <td>18</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11163.1700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>1</td>\n",
       "      <td>29</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9642.9990</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1</td>\n",
       "      <td>25</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9897.0490</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>1</td>\n",
       "      <td>27</td>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11142.8700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>1</td>\n",
       "      <td>17</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>16218.0400</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>1</td>\n",
       "      <td>24</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>995.7002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>584</th>\n",
       "      <td>0</td>\n",
       "      <td>37</td>\n",
       "      <td>8</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>648.7220</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>585</th>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1053.6190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>586</th>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>587</th>\n",
       "      <td>0</td>\n",
       "      <td>48</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1491.0260</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>588</th>\n",
       "      <td>0</td>\n",
       "      <td>55</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>589</th>\n",
       "      <td>0</td>\n",
       "      <td>21</td>\n",
       "      <td>15</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>590</th>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1730.4180</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>591</th>\n",
       "      <td>0</td>\n",
       "      <td>23</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3902.6760</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>592</th>\n",
       "      <td>0</td>\n",
       "      <td>46</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>593</th>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>14942.7700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>594</th>\n",
       "      <td>0</td>\n",
       "      <td>42</td>\n",
       "      <td>16</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>23764.8000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>595</th>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5306.5160</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>596</th>\n",
       "      <td>0</td>\n",
       "      <td>53</td>\n",
       "      <td>12</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>597</th>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "      <td>10</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3859.8220</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>598</th>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>599</th>\n",
       "      <td>0</td>\n",
       "      <td>43</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>600</th>\n",
       "      <td>0</td>\n",
       "      <td>34</td>\n",
       "      <td>12</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>601</th>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12242.9600</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>602</th>\n",
       "      <td>0</td>\n",
       "      <td>27</td>\n",
       "      <td>12</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1533.8800</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>603</th>\n",
       "      <td>0</td>\n",
       "      <td>51</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>604</th>\n",
       "      <td>0</td>\n",
       "      <td>39</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>964.9555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>605</th>\n",
       "      <td>0</td>\n",
       "      <td>55</td>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>606</th>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5551.8190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>607</th>\n",
       "      <td>0</td>\n",
       "      <td>27</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7543.7940</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>608</th>\n",
       "      <td>0</td>\n",
       "      <td>25</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>609</th>\n",
       "      <td>0</td>\n",
       "      <td>18</td>\n",
       "      <td>11</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>10150.5000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>610</th>\n",
       "      <td>0</td>\n",
       "      <td>24</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>19464.6100</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>611</th>\n",
       "      <td>0</td>\n",
       "      <td>21</td>\n",
       "      <td>18</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>612</th>\n",
       "      <td>0</td>\n",
       "      <td>32</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>187.6713</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>613</th>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1495.4590</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>614 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     treat  age  educ  black  hispan  married  nodegree  re74  re75  \\\n",
       "0        1   37    11      1       0        1         1   0.0   0.0   \n",
       "1        1   22     9      0       1        0         1   0.0   0.0   \n",
       "2        1   30    12      1       0        0         0   0.0   0.0   \n",
       "3        1   27    11      1       0        0         1   0.0   0.0   \n",
       "4        1   33     8      1       0        0         1   0.0   0.0   \n",
       "5        1   22     9      1       0        0         1   0.0   0.0   \n",
       "6        1   23    12      1       0        0         0   0.0   0.0   \n",
       "7        1   32    11      1       0        0         1   0.0   0.0   \n",
       "8        1   22    16      1       0        0         0   0.0   0.0   \n",
       "9        1   33    12      0       0        1         0   0.0   0.0   \n",
       "10       1   19     9      1       0        0         1   0.0   0.0   \n",
       "11       1   21    13      1       0        0         0   0.0   0.0   \n",
       "12       1   18     8      1       0        0         1   0.0   0.0   \n",
       "13       1   27    10      1       0        1         1   0.0   0.0   \n",
       "14       1   17     7      1       0        0         1   0.0   0.0   \n",
       "15       1   19    10      1       0        0         1   0.0   0.0   \n",
       "16       1   27    13      1       0        0         0   0.0   0.0   \n",
       "17       1   23    10      1       0        0         1   0.0   0.0   \n",
       "18       1   40    12      1       0        0         0   0.0   0.0   \n",
       "19       1   26    12      1       0        0         0   0.0   0.0   \n",
       "20       1   23    11      1       0        0         1   0.0   0.0   \n",
       "21       1   41    14      0       0        0         0   0.0   0.0   \n",
       "22       1   38     9      0       0        0         1   0.0   0.0   \n",
       "23       1   24    11      1       0        0         1   0.0   0.0   \n",
       "24       1   18    10      1       0        0         1   0.0   0.0   \n",
       "25       1   29    11      1       0        1         1   0.0   0.0   \n",
       "26       1   25    11      1       0        0         1   0.0   0.0   \n",
       "27       1   27    10      0       1        0         1   0.0   0.0   \n",
       "28       1   17    10      1       0        0         1   0.0   0.0   \n",
       "29       1   24    11      1       0        0         1   0.0   0.0   \n",
       "..     ...  ...   ...    ...     ...      ...       ...   ...   ...   \n",
       "584      0   37     8      1       0        0         1   0.0   0.0   \n",
       "585      0   17    10      1       0        0         1   0.0   0.0   \n",
       "586      0   16     8      0       0        0         1   0.0   0.0   \n",
       "587      0   48    12      0       0        1         0   0.0   0.0   \n",
       "588      0   55     7      0       0        0         1   0.0   0.0   \n",
       "589      0   21    15      0       0        0         0   0.0   0.0   \n",
       "590      0   16    10      1       0        0         1   0.0   0.0   \n",
       "591      0   23    12      0       0        0         0   0.0   0.0   \n",
       "592      0   46    11      1       0        1         1   0.0   0.0   \n",
       "593      0   17    10      0       0        0         1   0.0   0.0   \n",
       "594      0   42    16      0       0        0         0   0.0   0.0   \n",
       "595      0   18    10      1       0        0         1   0.0   0.0   \n",
       "596      0   53    12      1       0        0         0   0.0   0.0   \n",
       "597      0   17    10      0       0        1         1   0.0   0.0   \n",
       "598      0   17     6      0       0        0         1   0.0   0.0   \n",
       "599      0   43     6      0       0        1         1   0.0   0.0   \n",
       "600      0   34    12      1       0        0         0   0.0   0.0   \n",
       "601      0   16     8      0       1        0         1   0.0   0.0   \n",
       "602      0   27    12      0       0        1         0   0.0   0.0   \n",
       "603      0   51     4      1       0        0         1   0.0   0.0   \n",
       "604      0   39     2      1       0        1         1   0.0   0.0   \n",
       "605      0   55     8      0       0        1         1   0.0   0.0   \n",
       "606      0   16     9      0       0        0         1   0.0   0.0   \n",
       "607      0   27    10      1       0        0         1   0.0   0.0   \n",
       "608      0   25    14      0       0        0         0   0.0   0.0   \n",
       "609      0   18    11      0       0        0         1   0.0   0.0   \n",
       "610      0   24     1      0       1        1         1   0.0   0.0   \n",
       "611      0   21    18      0       0        0         0   0.0   0.0   \n",
       "612      0   32     5      1       0        1         1   0.0   0.0   \n",
       "613      0   16     9      0       0        0         1   0.0   0.0   \n",
       "\n",
       "           re78  \n",
       "0     9930.0460  \n",
       "1     3595.8940  \n",
       "2    24909.4500  \n",
       "3     7506.1460  \n",
       "4      289.7899  \n",
       "5     4056.4940  \n",
       "6        0.0000  \n",
       "7     8472.1580  \n",
       "8     2164.0220  \n",
       "9    12418.0700  \n",
       "10    8173.9080  \n",
       "11   17094.6400  \n",
       "12       0.0000  \n",
       "13   18739.9300  \n",
       "14    3023.8790  \n",
       "15    3228.5030  \n",
       "16   14581.8600  \n",
       "17    7693.4000  \n",
       "18   10804.3200  \n",
       "19   10747.3500  \n",
       "20       0.0000  \n",
       "21    5149.5010  \n",
       "22    6408.9500  \n",
       "23    1991.4000  \n",
       "24   11163.1700  \n",
       "25    9642.9990  \n",
       "26    9897.0490  \n",
       "27   11142.8700  \n",
       "28   16218.0400  \n",
       "29     995.7002  \n",
       "..          ...  \n",
       "584    648.7220  \n",
       "585   1053.6190  \n",
       "586      0.0000  \n",
       "587   1491.0260  \n",
       "588      0.0000  \n",
       "589      0.0000  \n",
       "590   1730.4180  \n",
       "591   3902.6760  \n",
       "592      0.0000  \n",
       "593  14942.7700  \n",
       "594  23764.8000  \n",
       "595   5306.5160  \n",
       "596      0.0000  \n",
       "597   3859.8220  \n",
       "598      0.0000  \n",
       "599      0.0000  \n",
       "600      0.0000  \n",
       "601  12242.9600  \n",
       "602   1533.8800  \n",
       "603      0.0000  \n",
       "604    964.9555  \n",
       "605      0.0000  \n",
       "606   5551.8190  \n",
       "607   7543.7940  \n",
       "608      0.0000  \n",
       "609  10150.5000  \n",
       "610  19464.6100  \n",
       "611      0.0000  \n",
       "612    187.6713  \n",
       "613   1495.4590  \n",
       "\n",
       "[614 rows x 10 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv(\"../trailblazer/trailblazer4ml/causal_inference/datasets/data/lalonde.csv\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "75e59200-aa0d-415d-ad95-9caa717a1ef0",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:13.949038Z",
     "shell.execute_reply.started": "2023-03-10T04:58:13.941649Z",
     "to_execute": "2023-03-10T04:58:13.850Z"
    }
   },
   "outputs": [],
   "source": [
    "covariates = ['age', 'educ', 'black', 'hispan', 'married', 'nodegree']\n",
    "treat = ['treat']\n",
    "outcomes = ['re78']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7aa0ad28-856a-4dd4-9f46-aa33fcb9195b",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:17.074325Z",
     "shell.execute_reply.started": "2023-03-10T04:58:17.058951Z",
     "to_execute": "2023-03-10T04:58:16.963Z"
    }
   },
   "outputs": [],
   "source": [
    "data = EasyDataset(df, covariates, treat, outcomes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "09f2e1f5-8305-4e9c-beb3-462b63270b5e",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:19.915847Z",
     "shell.execute_reply.started": "2023-03-10T04:58:19.905287Z",
     "to_execute": "2023-03-10T04:58:19.804Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[3.700000e+01, 1.100000e+01, 1.000000e+00, ..., 1.000000e+00,\n",
       "        1.000000e+00, 9.930046e+03],\n",
       "       [2.200000e+01, 9.000000e+00, 0.000000e+00, ..., 1.000000e+00,\n",
       "        1.000000e+00, 3.595894e+03],\n",
       "       [3.000000e+01, 1.200000e+01, 1.000000e+00, ..., 0.000000e+00,\n",
       "        1.000000e+00, 2.490945e+04],\n",
       "       ...,\n",
       "       [2.100000e+01, 1.800000e+01, 0.000000e+00, ..., 0.000000e+00,\n",
       "        0.000000e+00, 0.000000e+00],\n",
       "       [3.200000e+01, 5.000000e+00, 1.000000e+00, ..., 1.000000e+00,\n",
       "        0.000000e+00, 1.876713e+02],\n",
       "       [1.600000e+01, 9.000000e+00, 0.000000e+00, ..., 1.000000e+00,\n",
       "        0.000000e+00, 1.495459e+03]])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.get_data_array()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f4f899f6-b75c-48be-bae3-34ce47562260",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:20.735886Z",
     "shell.execute_reply.started": "2023-03-10T04:58:20.728853Z",
     "to_execute": "2023-03-10T04:58:20.634Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Data size: 614\n"
     ]
    }
   ],
   "source": [
    "ex1 = FCM(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "9c64c990-2a03-4c7e-93c3-23bc2e19a36c",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:23.290764Z",
     "shell.execute_reply.started": "2023-03-10T04:58:23.171438Z",
     "to_execute": "2023-03-10T04:58:23.079Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>method</th>\n",
       "      <th>edge_start</th>\n",
       "      <th>edge_end</th>\n",
       "      <th>estimate_value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ICALiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>-0.855251</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ICALiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>-1.999377</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ICALiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>6.696211</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ICALiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>-4.011331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ICALiNGAM</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>-0.823587</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      method  edge_start  edge_end  estimate_value\n",
       "0  ICALiNGAM           0         1       -0.855251\n",
       "1  ICALiNGAM           0         3       -1.999377\n",
       "2  ICALiNGAM           0         4        6.696211\n",
       "3  ICALiNGAM           0         5       -4.011331\n",
       "4  ICALiNGAM           1         3       -0.823587"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex1._get_adjacent_matrix(method = 'ICALiNGAM').head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "0f40bde7-d568-4838-bead-60d8185d39e7",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:24.385401Z",
     "shell.execute_reply.started": "2023-03-10T04:58:24.037548Z",
     "to_execute": "2023-03-10T04:58:23.940Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>method</th>\n",
       "      <th>edge_start</th>\n",
       "      <th>edge_end</th>\n",
       "      <th>estimate_value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>DirectLiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>-0.895895</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>DirectLiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>-2.091487</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>DirectLiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>6.525797</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>DirectLiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>-4.032762</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>DirectLiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0.000066</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         method  edge_start  edge_end  estimate_value\n",
       "0  DirectLiNGAM           0         1       -0.895895\n",
       "1  DirectLiNGAM           0         3       -2.091487\n",
       "2  DirectLiNGAM           0         4        6.525797\n",
       "3  DirectLiNGAM           0         5       -4.032762\n",
       "4  DirectLiNGAM           0         7        0.000066"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex1._get_adjacent_matrix(method = 'DirectLiNGAM').head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "88526cd8-d0e0-4c58-94bd-1a56e2dd8274",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:58:27.478773Z",
     "shell.execute_reply.started": "2023-03-10T04:58:27.044418Z",
     "to_execute": "2023-03-10T04:58:26.952Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>method</th>\n",
       "      <th>edge_start</th>\n",
       "      <th>edge_end</th>\n",
       "      <th>estimate_value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>VARLiNGAM</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>6.756197</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>VARLiNGAM</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>-0.381675</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>VARLiNGAM</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>-3.123555</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>VARLiNGAM</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>-0.335279</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>VARLiNGAM</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>-0.124582</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      method  edge_start  edge_end  estimate_value\n",
       "0  VARLiNGAM           0         4        6.756197\n",
       "1  VARLiNGAM           1         3       -0.381675\n",
       "2  VARLiNGAM           1         5       -3.123555\n",
       "3  VARLiNGAM           2         3       -0.335279\n",
       "4  VARLiNGAM           2         4       -0.124582"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex1._get_adjacent_matrix(method = 'VARLiNGAM').head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "f71b55bd-b8a8-4188-90d7-2bc13fcd1001",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:59:00.841947Z",
     "shell.execute_reply.started": "2023-03-10T04:58:29.609240Z",
     "to_execute": "2023-03-10T04:58:29.513Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>method</th>\n",
       "      <th>edge_start</th>\n",
       "      <th>edge_end</th>\n",
       "      <th>estimate_value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>RCD</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>RCD</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>RCD</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>RCD</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>RCD</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  method  edge_start  edge_end  estimate_value\n",
       "0    RCD           0         1             NaN\n",
       "1    RCD           0         2             NaN\n",
       "2    RCD           0         4             NaN\n",
       "3    RCD           0         7             NaN\n",
       "4    RCD           1         0             NaN"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex1._get_adjacent_matrix(method = 'RCD').head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "9917b5cb-81ca-49a0-9c73-fba68d96de75",
   "metadata": {
    "execution": {
     "shell.execute_reply.end": "2023-03-10T04:59:01.214692Z",
     "shell.execute_reply.started": "2023-03-10T04:59:00.851177Z",
     "to_execute": "2023-03-10T04:58:32.079Z"
    }
   },
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "module 'causallearn.search.FCMBased.lingam' has no attribute 'CAMUV'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[0;32m/tmp/ipykernel_28184/1122945312.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mex1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_adjacent_matrix\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmethod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'CAMUV'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m/opt/conda/lib/python3.7/site-packages/trailblazer4ml/causal_discovery/estimators/FCM_based.py\u001b[0m in \u001b[0;36m_get_adjacent_matrix\u001b[0;34m(self, method, random_seed)\u001b[0m\n\u001b[1;32m     60\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     61\u001b[0m         \u001b[0;32melif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"CAMUV\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 62\u001b[0;31m             \u001b[0mP\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mU\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlingam\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mCAMUV\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexecute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_dataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_data_array\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0malpha\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0.01\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnum_explanatory_vals\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     63\u001b[0m             \u001b[0medge_list0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0medge_list1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     64\u001b[0m             \u001b[0mvalue_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mAttributeError\u001b[0m: module 'causallearn.search.FCMBased.lingam' has no attribute 'CAMUV'"
     ]
    }
   ],
   "source": [
    "ex1._get_adjacent_matrix(method = 'CAMUV').head()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  },
  "record_timing": true
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
